package com.data.modules.online.auth.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;

import com.data.common.system.vo.SysPermissionDataRuleModel;
import com.data.modules.online.auth.entity.OnlAuthData;
import com.data.modules.online.auth.entity.OnlAuthRelation;
import com.data.modules.online.auth.mapper.OnlAuthDataMapper;
import com.data.modules.online.auth.mapper.OnlAuthRelationMapper;
import com.data.modules.online.auth.service.IOnlAuthDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("onlAuthDataServiceImpl")
public class OnlAuthDataServiceImpl extends ServiceImpl<OnlAuthDataMapper, OnlAuthData> implements IOnlAuthDataService {
    @Autowired
    private OnlAuthRelationMapper onlAuthRelationMapper;

    private static /* synthetic */ java.lang.Object m30a(java.lang.invoke.SerializedLambda r3) {
        /*
        // Method dump skipped, instructions count: 118
        */
        throw new UnsupportedOperationException("Method not decompiled: com.data.modules.online.auth.service.p004a.OnlAuthDataServiceImpl.m30a(java.lang.invoke.SerializedLambda):java.lang.Object");
    }

    @Override
    public void deleteOne(String id) {
        this.removeById(id);
        LambdaQueryWrapper<OnlAuthRelation> var2 = new LambdaQueryWrapper<OnlAuthRelation>();
        this.onlAuthRelationMapper.delete(var2.eq(OnlAuthRelation::getAuthId, id));

    }

    @Override
    public List<SysPermissionDataRuleModel> queryUserOnlineAuthData(String userId, String cgformId) {
        List<SysPermissionDataRuleModel> queryRoleAuthData = this.baseMapper.queryRoleAuthData(userId, cgformId);
        List<SysPermissionDataRuleModel> queryDepartAuthData = this.baseMapper.queryDepartAuthData(userId, cgformId);
        List<SysPermissionDataRuleModel> queryUserAuthData = this.baseMapper.queryUserAuthData(userId, cgformId);
        HashMap hashMap = new HashMap();
        for (SysPermissionDataRuleModel sysPermissionDataRuleModel : queryRoleAuthData) {
            String id = sysPermissionDataRuleModel.getId();
            if (hashMap.get(id) == null) {
                hashMap.put(id, sysPermissionDataRuleModel);
            }
        }
        for (SysPermissionDataRuleModel sysPermissionDataRuleModel2 : queryDepartAuthData) {
            String id2 = sysPermissionDataRuleModel2.getId();
            if (hashMap.get(id2) == null) {
                hashMap.put(id2, sysPermissionDataRuleModel2);
            }
        }
        for (SysPermissionDataRuleModel sysPermissionDataRuleModel3 : queryUserAuthData) {
            String id3 = sysPermissionDataRuleModel3.getId();
            if (hashMap.get(id3) == null) {
                hashMap.put(id3, sysPermissionDataRuleModel3);
            }
        }
        Collection values = hashMap.values();
        if (values == null || values.size() == 0) {
            return null;
        }
        return new ArrayList(values);
    }
}